#coding=utf-8
# from models import *
# import datetime
# 
# def inittoken(newtoken='111111'):
#     try:
#         token = TokenModel(token=newtoken)
#         token.save()
#         #print 'add token'
#         return True
#     except:
#         return False
# 
# def updatetoken(newtoken, token='111111'):
#     try:
#         Token = TokenModel.objects(token=token)[0]
#         print Token
#         if Token :
#             Token.token = newtoken
#             Token.modifiedtime = datetime.datetime.now
#             Token.save()
#             #print 'yes token'
#             return True
#         else:
#             inittoken(newtoken)
#             #print 'no token'
#             return True
#         
#     except:
#         return False
# 
# def renewtoken(token='111111'):
#     try:
#         Token = TokenModel.objects
#         Token.delete()
#     except:
#         return False
#     return inittoken()
#     
# def checktoken(token):
#     try:
#         Token = TokenModel.objects(token=token)[0]
#         if Token:
#             return True
#     except:
#         return False
# 
# 
# #token = '122222'
# #print updatetoken(token,'222222')
# 
# #for t in TokenModel.objects:
# #    print t.token
# 
# # renewtoken()
# # for t in TokenModel.objects:
# #     print t.token
